package pro.shushi.pamirs.demo.core.mq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import pro.shushi.pamirs.framework.connectors.event.engine.NotifyEvent;
import pro.shushi.pamirs.framework.connectors.event.rocketmq.RocketMQProducer;
import pro.shushi.pamirs.meta.api.session.PamirsSession;
import pro.shushi.pamirs.workflow.app.api.constant.WorkflowConstant;

@Component
public class DemoItemMQProducer {
    public static final String PAMIRS_MESSAGE_DEMO_ITEM_TOPIC = "PAMIRS_MESSAGE_DEMO_ITEM_TOPIC";

    @Autowired
    private RocketMQProducer rocketMQProducer;

    /**
     * 发送普通消息
     */
    public void sendNormalMessage(String data, String msgId) {
        rocketMQProducer.send(new NotifyEvent(PAMIRS_MESSAGE_DEMO_ITEM_TOPIC, null, data)
                .putProperty(PAMIRS_MESSAGE_DEMO_ITEM_TOPIC, msgId)
//                .putProperty("traceId", PamirsSession.getRequestVariables().getTraceId())
        );
    }
}
